package com.edu.exam.enums.examination;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 违规类型枚举
 */
@Getter
@AllArgsConstructor
public enum ViolationType {
    CHEATING("CHEATING", "作弊"),
    UNAUTHORIZED_ACCESS("UNAUTHORIZED_ACCESS", "未授权访问"),
    PROHIBITED_ITEMS("PROHIBITED_ITEMS", "违禁物品"),
    IDENTITY_FRAUD("IDENTITY_FRAUD", "身份欺诈"),
    COMMUNICATION_VIOLATION("COMMUNICATION_VIOLATION", "通讯违规"),
    TIME_VIOLATION("TIME_VIOLATION", "时间违规"),
    BEHAVIOR_VIOLATION("BEHAVIOR_VIOLATION", "行为违规"),
    SYSTEM_VIOLATION("SYSTEM_VIOLATION", "系统违规"),
    SECURITY_BREACH("SECURITY_BREACH", "安全泄露"),
    SUSPICIOUS_ACTIVITY("SUSPICIOUS_ACTIVITY", "可疑活动"),
    TECHNICAL_VIOLATION("TECHNICAL_VIOLATION", "技术违规");

    private final String code;
    private final String description;

    public static ViolationType fromCode(String code) {
        for (ViolationType type : values()) {
            if (type.getCode().equals(code)) {
                return type;
            }
        }
        return SUSPICIOUS_ACTIVITY; // 默认返回可疑活动
    }
}